package com.gitee.wsl.markdown

import timber.log.Timber

/**
 * @see LinkResolverDef
 *
 * @see MarkwonConfiguration.Builder.linkResolver
 * @since 4.0.0
 */
fun interface LinkResolver {
    fun resolve(link: String)
}

/*
class LinkResolverDef : LinkResolver {
    override fun resolve(view: View, link: String) {
        val uri = parseLink(link)
        val context = view.context
        val intent = Intent(Intent.ACTION_VIEW, uri)
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.packageName)
        try {
            context.startActivity(intent)
        } catch (e: ActivityNotFoundException) {
            Timber.e( "Actvity was not found for the link: '$link'")
        }
    }

    companion object {
        // @since 4.3.0
        private const val DEFAULT_SCHEME = "https"

        */
/**
         * @since 4.3.0
         *//*

        private fun parseLink(link: String): Uri {
            val uri = Uri.parse(link)
            return if (TextUtils.isEmpty(uri.scheme)) {
                uri.buildUpon()
                    .scheme(DEFAULT_SCHEME)
                    .build()
            } else uri
        }
    }
}*/
